class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  protected

  def protect_administrator!
    unless (current_user && current_user.is_admin?)
      redirect_to root_path, flash: {alert: t("errors.need_admin_role")}
    end
  end


  def after_sign_in_path_for(resource)
    if resource.is_admin? 
      admin_users_path
    else
      root_path
    end
  end

end
